package com.xixi.example.consumer;

import com.xixi.core.rpc.proxy.ServiceProxyFactory;
import com.xixi.example.common.model.User;
import com.xixi.example.common.service.UserService;

/**
 * @author: zxh
 * @date: 2024/8/20 23:00
 * @description:
 */
public class EasyConsumerExample {

	public static void main(String[] args) {
		// todo 需要获取 UserService 的实现类对象
		// 使用静态代理
		// UserService userService = new UserServiceProxy();
		// 动态代理
		System.out.println("开始代理");
		UserService userService = ServiceProxyFactory.getProxy(UserService.class);
		System.out.println("代理对象获取完毕");
		User user = new User();
		user.setName("张三");
		// 调用
		System.out.println("调用getUser");
		User newUser = userService.getUser(user);
		System.out.println("getUser调用完毕");
		System.out.println("调用getOther");
		User newUser1 = userService.getOtherUser();
		System.out.println("getOther调用完毕");
		if (newUser != null) {
			System.out.println(newUser.getName());
		} else {
			System.out.println("user == null");
		}
	}
}
